package com.cxg.allsys.memsys.controller;

import com.cxg.allsys.memsys.pojo.Article;
import com.cxg.allsys.memsys.service.IFaBuService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api")
@Slf4j
@RestController
@Data
@CrossOrigin
public class FaBuController {
    @Autowired
    private IFaBuService fabuService;
    //会员发布接口查询
    @RequestMapping("/Member/MemberFaBu")
    public List<Article> memberFaBu(){
        log.info("FaBuController控制器运行memberFaBu方法");
        return fabuService.query();
    }
    //会员发布接口查询
    @RequestMapping("/Member/MemberChaXun")
    public Article memberChaXun(Integer id){
        log.info("FaBuController控制器运行memberChaXun方法");
        log.info(String.valueOf(id));
        return fabuService.queryid(id);
    }
    //发布文章
    @RequestMapping("/Member/WenzFaBu")
    public boolean wenzFaBu(Article article){
        log.info("FaBuController控制器运行wenzFaBu方法");
        log.info(String.valueOf(article));
        boolean falg = fabuService.insert(article);
        if(falg){
            return true;
        }else{
            return false;
        }
    }
    //更新文章
    @RequestMapping("/Member/WenzGenXin")
    public boolean wenzGenXin(Article article){
        log.info("FaBuController控制器运行wenzGenXin方法");
        log.info(String.valueOf(article));
        boolean falg = fabuService.update(article);
        if(falg){
            return true;
        }else{
            return false;
        }
    }
    //删除文章
    @RequestMapping("/Member/WenzShanChu")
    public boolean wenzShanChu(Integer id){
        log.info("FaBuController控制器运行wenzShanChu方法");
        boolean falg = fabuService.delete(id);
        if(falg){
            return true;
        }else{
            return false;
        }
    }
}
